layui.use('layer',function() {
    var layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;
})
$("#recover").click(function () {
    var punsterName = $("#punstername").val();
    var email = $("#email").val();
    $.ajax({
        url : "recPassword",
        type : "GET",
        data:{
            punsterName : punsterName,
            email : email
        },
        success : function (result) {
            if (result.code == 100){
                layer.msg(result.extend.Msg,{offset:'300px' });
            } else {
                layer.msg(result.extend.Msg,{offset:'300px' });
            }


        }
    })
})

$("#reset").click(function () {
    var code = $("#CHECK_CODE").val();
    var userId = $("#hId").val();
    var pwd = $("#pwd").val();
    var pwd2 = $("#pwd2").val();
    if (pwd == "" || pwd == undefined || pwd == null){
        layer.msg("密码不能为空",{offset:'300px' });
    } else {
        if ( pwd == pwd2) {
            $.ajax({
                url : "changePwdByCode",
                type : "GET",
                data : {
                    userId : userId,
                    check_code : code,
                    newPwd : pwd
                },
                success : function (result) {
                    if (result.code == 100) {
                        alert("修改成功");
                        window.location.href="layout";
                    } else {
                        setTimeout(function(){
                            layer.msg(result.extend.msg,{offset:'300px' });
                        },1000);
                    }
                }
            })
        } else {
            layer.msg("俩次输入密码不同",{offset:'300px' });
        }
    }


})